$toggle-height: 32px;
$toggle-full-width-breakpoint: 520px;

.md-settings__dropdown-toggle {
    display: flex;
    align-items: center;
    color: $secondary-text;
    background: white;
    border: 1px solid $light-stroke;
    font: $medium 13px/16px $lato;
    letter-spacing: 0.01em;
    border-radius: 4px;
    padding: 4px 10px 4px 12px;
    height: $toggle-height;
    cursor: pointer;

    svg {
        font-size: 12px;
        margin-left: 8px;
    }

    &--hidden {
        position: absolute;
        visibility: hidden;
    }

    &:focus-visible {
        // Override global focus-visible style.
        outline: none !important;
    }

    &:hover:not([data-disabled]),
    &:focus:not([data-disabled]) {
        border-color: $blue-30;
    }

    &:hover {
        background: $gray-5;
    }

    &[data-pressed],
    &:active {
        background: $active-fill;
        border: 1px solid $active-fill;
    }

    &[data-pressed] {
        cursor: default;
        color: $active-text;
    }

    &[data-disabled] {
        color: $gray-60;
        cursor: default;
        background: $gray-5;

        .md-settings__dropdown-current-choice {
            color: $gray-70;
        }
    }

    @media (max-width: $toggle-full-width-breakpoint) {
        width: 100%;
    }
}

.md-settings__dropdown-label {
    white-space: nowrap;

    &::after {
        content: ":";
        margin-right: 3px;
    }
}

.md-settings__dropdown-current-choice {
    color: $primary-text;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    margin-left: auto;

    @media (max-width: $toggle-full-width-breakpoint) {
        max-width: none;
    }
}

.md-settings__dropdown {
    @media (max-width: $toggle-full-width-breakpoint) {
        width: 100%;
    }
}

.md-menu {
    width: 400px;
    background: white;
    padding: 16px 16px 8px;
    border-radius: 4px;
    box-shadow: 0px 4px 23px 4px #0000000f;
    z-index: $zindex-controls-popup;
    overflow-y: auto;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;

    // Reduce right padding in webkit browsers to accommodate scrollbar
    @supports selector(::-webkit-scrollbar) {
        padding-right: 6px;
    }

    // Always show scrollbar in webkit browsers. This makes it clear that there
    // are more options to scroll through.
    &::-webkit-scrollbar {
        width: 11px;
    }

    &::-webkit-scrollbar-track {
        background: transparent;
    }

    &::-webkit-scrollbar-thumb {
        background-clip: content-box;
        background-color: $gray-70;
        border-radius: 11px;
        border: 3px solid transparent;
    }

    .md-menu__overlay-header {
        display: flex;
        justify-content: space-between;
        margin-bottom: 12px;
    }

    .md-menu__overlay-header-title {
        @include h5-black-caps;
        color: $light-text;

        // Align with the close button. We don't use align-items: center,
        // because the children below the title can have arbitrary height.
        margin-top: 9px;
        margin-bottom: 4px;
    }

    .md-menu__overlay-header-close-button {
        margin-left: 8px;
    }

    .md-menu__dimension-description {
        color: $gray-70;
        font-size: 13px;
        line-height: normal;
        margin-top: 0;
        margin-bottom: 4px;
    }

    .md-label {
        @include label-2-regular;
        display: block;
    }

    .md-description {
        @include note-2-regular;
        display: block;
        color: $gray-70;
        margin-top: 4px;
    }

    .md-menu__group {
        margin-bottom: 16px;

        &:last-child {
            margin-bottom: 0;
        }
    }

    .md-menu__group-label {
        @include label-2-bold;
        color: $light-text;
        margin: 16px 0;
    }

    .md-menu__radio-button {
        padding: 16px 0;
        border-bottom: 1px solid $gray-20;
        cursor: pointer;

        &:focus-visible {
            outline: none !important;
        }

        &:first-of-type {
            padding-top: 0;
        }

        &:last-of-type {
            border-bottom: none;
        }
    }

    @include sm-only {
        width: 264px;
    }
}
